<?php

require_once dirname(__FILE__) . '/../../../Domain51UnitTest.config.php';
require_once 'Domain51/Model/Meta/Abstract.php';

class Domain51_Model_Meta_AbstractTestable extends Domain51_Model_Meta_Abstract
{
    // blank class to test abstract functionality
}

class Domain51_Model_Meta_AbstractTest extends PHPUnit_Framework_TestCase
{
    public function testAnswerTable_namePropertyBasedOnConfig()
    {
        $this->markTestSkipped();
        $config = array('table_name' => $this->_tableName);
        $meta = new Domain51_Model_Meta_AbstractTestable($config);
        
        $this->assertTrue(is_string($config['table_name']));
        $this->assertSame($config['table_name'], $meta->table_name);
    }
    
    public function testThrowsExceptionOnEmptyTable_nameConfigValue()
    {
        $this->markTestSkipped();
        $config = array('table_name' => null);
        
        try {
            $meta = new Domain51_Model_Meta_AbstractTestable($config);
            $this->fail('Exception not caught');
        } catch (Solar_Exception $e) {
            $this->assertSame('ERR_CONFIG_VALUE_INVALID', $e->getCode());
            $this->assertSame(array('table_name' => null), $e->getInfo());
        }
        unset($config);
        unset($meta);
        
        try {
            $meta = new Domain51_Model_Meta_AbstractTestable();
            $this->fail('Exception not caught');
        } catch (Solar_Exception $e) {
            $this->assertSame('ERR_CONFIG_VALUE_INVALID', $e->getCode());
            $this->assertSame(array('table_name' => null), $e->getInfo());
        }
        unset($meta);
        
        $config = array('table_name' => '');
        try {
            $meta = new Domain51_Model_Meta_AbstractTestable($config);
            $this->fail('Exception not caught');
        } catch (Solar_Exception $e) {
            $this->assertSame('ERR_CONFIG_VALUE_INVALID', $e->getcode());
            $this->assertSame($config, $e->getInfo());
        }
    }
}

?>